/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.udt.generator;

import com.inspur.edp.caf.generator.module.ModuleGenerator;
import com.inspur.edp.cef.generator.apiGenerator.CefApiGenerator;
import com.inspur.edp.cef.generator.configGenerator.CefConfigGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.CefCoreGenerator;
import com.inspur.edp.cef.generator.entityGenerator.BaseEntityGenerator;
import com.inspur.edp.cef.generator.overall.CefGenerator;
import com.inspur.edp.cef.generator.overall.CefGeneratorContext;
import com.inspur.edp.cef.generator.repository.base.CefRepositoryGenerstor;
import com.inspur.edp.jittojava.context.JitContext;
import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
import com.inspur.edp.udt.designtime.api.entity.UnifiedDataTypeDef;
import com.inspur.edp.udt.generator.api.UdtApiGenerator;
import com.inspur.edp.udt.generator.config.UdtConfigGenerator;
import com.inspur.edp.udt.generator.core.UdtCoreGenerator;
import com.inspur.edp.udt.generator.entity.UdtEntityGenerator;

public class UdtGenerator extends CefGenerator
{
	public UdtGenerator(String path, GspMetadata metadata, boolean preGenerating, ModuleGenerator refGenerator, JitContext metadataJitContext)
	{
		super(path, metadata, preGenerating, refGenerator, metadataJitContext);
	}

	public UdtGenerator(String path, GspMetadata metadata, CefGeneratorContext refGenCtx, ModuleGenerator refGenerator, JitContext metadataJITContext)
	{
		super(path, metadata,refGenCtx,refGenerator,metadataJITContext);

	}

	private UdtGeneratorContext getUdtGenContext(){return (UdtGeneratorContext)super.getContext();}

	@Override
	protected CefApiGenerator createApiGenerator()
	{
		return new UdtApiGenerator(getUdtGenContext());
	}


	@Override
	protected final CefGeneratorContext createCefGeneratorContext()
	{
		UdtGeneratorContext context = new UdtGeneratorContext((UnifiedDataTypeDef)metadata.getContent());
		return context;
	}

	@Override
	protected CefConfigGenerator createConfigGenerator()
	{
		return new UdtConfigGenerator(getUdtGenContext());
	}

	public boolean isHasRepository() {
		return true;
	}


	@Override
	protected CefCoreGenerator createCoreGenerator()
	{
		return new UdtCoreGenerator(getUdtGenContext());
	}

	@Override
	protected BaseEntityGenerator createEntityGenerator()
	{
		return new UdtEntityGenerator(getUdtGenContext());
	}
}
